<template>
    <div>
        <VoSchemaForm :model="model" :schema="schema"></VoSchemaForm>
        <div>
            <pre>{{modelJson}}</pre>
        </div>
        <div class="markdown-body">
            <CodeTpl></CodeTpl>
        </div>
    </div>
</template>

<script>
import CodeTpl from '@/views/md/sf/upload.md';
export default {
    components: {
        CodeTpl
    },
    data() {
        return {
            model: {},
            schema: {
                properties: {
                    name1: {
                        label: '上传',
                        widget: 'upload',
                        ui: {
                            action: 'https://jsonplaceholder.typicode.com/posts/'
                        }
                    },
                    name2: {
                        label: '请求处理',
                        widget: 'upload',
                        ui: {
                            action: 'https://jsonplaceholder.typicode.com/posts/'
                        },
                        custom: {
                            handleResponse({ fileList }, resolve) {
                                console.log(fileList);
                                resolve(fileList.map(e => {
                                    if (e.response) {
                                        return { name: e.name }
                                    } else {
                                        return e
                                    }
                                }))
                            }
                        }
                    }
                },
                ui: {
                    labelWidth: 100
                },
                col: {
                    span: 12
                }
            }
        }
    },
    computed: {
        modelJson() {
            return JSON.stringify(this.model, null, 4)
        }
    }
}
</script>

<style>

</style>
